<!DOCTYPE html>
<html>
	<head itemprop="video" itemscope itemtype="//schema.org/VideoObject"><meta charset="UTF-8">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/FileSaver.min.js"></script>
		<script type="text/javascript" src="js/jszip.min.js"></script>
		<script type="text/javascript" src="js/jquery-loading.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/table.css">
		<link rel="stylesheet" type="text/css" href="css/button.css">
	</head>
	<body>
		<table class='gridtable'>
			<tr>
	            <th>功能</th><th>#</th><th>上传耗时</th><th>计算耗时</th><th>下载耗时</th>
	        </tr>
	        <tr>
	            <td>TKA分割</td><td><button class='button' onclick="TKA()">上传</button></td><td>0ms</td><td>0ms</td><td>0ms</td>
	        </tr>
	        <tr>
	            <td>腰椎自动规划</td><td><button class='button'>上传</button></td><td>0ms</td><td>0ms</td><td>0ms</td>
	        </tr>
	        <tr>
	            <td>腰椎CBCT图像质量优化</td><td><button class='button'>上传</button></td><td>0ms</td><td>0ms</td><td>0ms</td>
	        </tr>
		</table>
	</body>
	<script type="text/javascript">
		// 点击TKA下载时触发此方法
		function TKA(){
			// 显示loadingg
			$('body').loading({message: '加载中'})
			// 隐藏loading
			//$('body').loading('toggle')
		}

		function dw(){
			fetch('http://localhost:8000')
			.then(function(response){
				if(response.status === 200 ||response.status === 0){
					return Promise.resolve(response.blob());
				}else{
					return Promise.reject(new Error(response.statusText));
				}
			})
			.then(JSZip.loadAsync)
			.then(function(zip){
				var blobs = []
				for(var file in zip.files){
					console.log(file)
					if(zip.file(file).dir){
						continue;
					}
					(function(fileinfo){
						zip.file(file).async('blob').then(function(data){
							saveAs(data, fileinfo)
						})
					})(file)
				}
			})
		}
	</script>
</html>